package com.dtease.agent.core.enums;


/**
* @description 数据源类型枚举
* @author chentl
* @class StorageTypeEnum
* @package com.dtease.agent.metadata.enums
* @since 2025/5/7 14:05
*/
public enum StorageTypeEnum {

    MYSQL(1, "MySQL"),

    ORACLE(2, "Oracle"),

    SQLSERVER(3, "SQLServer"),

    HIVE(4, "Hive"),

    OPEN_TSDB(5, "OpenTSDB"),

    ES(6, "ElasticSearch"),

    KAFKA(7, "Kafka"),

    API(8, "Api"),

    FILE(9, "文件"),

    GREEN_PLUM(10, "Greenplum"),

    POSTGRESQL(11, "PostgreSQL"),

    ODPS(12, "ODPS"),

    MONGODB(13, "MongoDB"),

    HBASE(14, "HBase"),

    OTS(15, "OTS"),

    ADS(16, "ADS"),

    HDFS(17, "HDFS"),

    OSS(18, "OSS"),

    LIBRA(19, "LibrA"),

    DB2(20, "DB2"),

    FTP(21, "FTP"),

    PHOENIX(22, "PHOENIX"),

    HANA(24, "HANA"),

    ELK(25, "ELK"),

    KUDU(26, "KUDU"),

    IMPALA(27,"IMPALA"),

    REDIS(28, "Redis"),

    SOLR(45, "Solr"),

    DUBBO(30, "Dubbo"),

    ANALYTICDB_POSTGRESQL(46, "AnalyticDB_PostgreSQL"),

    SOCKET(72, "SOCKET"),
    ;



    private final Integer storageType;
    private final String storageTypeName;


    StorageTypeEnum(Integer storageType, String storageTypeName) {
        this.storageType = storageType;
        this.storageTypeName = storageTypeName;
    }

    public Integer getStorageType() {
        return storageType;
    }

    public String getStorageTypeName() {
        return storageTypeName;
    }

    public static String getStorageTypeName(Integer type) {
        for (StorageTypeEnum storageTypeEnum : StorageTypeEnum.values()) {
            if (storageTypeEnum.getStorageType().equals(type)) {
                return storageTypeEnum.getStorageTypeName();
            }
        }
        return null;
    }

    public static StorageTypeEnum getEnumByName(String storageTypeName) {
        for (StorageTypeEnum storageTypeEnum : StorageTypeEnum.values()) {
            if (storageTypeEnum.getStorageTypeName().equals(storageTypeName)) {
                return storageTypeEnum;
            }
        }
        throw new RuntimeException("数据源不存在");
    }
}

